//
//  HessianClient.m
//  YouthOlympic2014
//
//  Created by Li Yuhang on 14-6-30.
//  Copyright (c) 2014年 mitian. All rights reserved.
//

#import "HessianClient.h"


@implementation HessianClient

//singleton
static HessianClient *instance;
+ (HessianClient *)createInstance{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[HessianClient alloc] init];
    });
    return instance;
}



- (id<BasicAPI>) create{
    NSString *url = API_URL;
    
    //
    //[CWHessianArchiver setMethodName:@"say" forSelector:@selector(say:)];
    
    [CWHessianArchiver setMethodName:@"GetGameInfo" forSelector:@selector(GetGameInfo:withLan:)];
    [CWHessianArchiver setMethodName:@"GetGameSubTypeInfo" forSelector:@selector(GetGameSubTypeInfoByType:withLan:)];
    [CWHessianArchiver setMethodName:@"GetGameDetailInfoByTypeAndSubTypeAndDate" forSelector:@selector(GetgameDetailInfoByType:andSubType:andGameDate:withLan:)];
    [CWHessianArchiver setMethodName:@"GetGameDetailInfoPlace" forSelector:@selector(GetGameDetailInfoPlace:andSubPlace:andGameDate:withLan:)];
    [CWHessianArchiver setMethodName:@"GetDateMarksByTypeAndSubType" forSelector:@selector(GetDateMarksByType:andSubType:withLan:)];
    
    [CWHessianArchiver setMethodName:@"SelectAllCepActive" forSelector:@selector(SelectAllCepActive:withLan:)];
    [CWHessianArchiver setMethodName:@"SelectTheOneCepActive" forSelector:@selector(SelectTheOneCepActive:andUserId:withLan:)];
    
    [CWHessianArchiver setMethodName:@"getLocation" forSelector:@selector(GetLocation:)];
    [CWHessianArchiver setMethodName:@"GetSubLocation" forSelector:@selector(GetSubLocation:withLan:)];
    
    [CWHessianArchiver setMethodName:@"GetDateMarksByPlace" forSelector:@selector(GetDateMarksByPlace:andSubPlace:withLan:)];
    
    [CWHessianArchiver setMethodName:@"InputIphoneDevNo" forSelector:@selector(InputIphoneDevNo:userId:)];
    
    [CWHessianArchiver setMethodName:@"GetWeather" forSelector:@selector(GetWeather:withLan:)];
    
    NSURL* cUrl = [NSURL URLWithString:url];
    CWHessianConnection* connection = [[CWHessianConnection alloc] initWithHessianVersion:CWHessianVersion1_00];
    return (id<BasicAPI>)[connection proxyWithURL:cUrl protocol:@protocol(BasicAPI)]; //设置代理类
}



@end
